<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/common/common-css.jsp" %>
	<style>
#jquery-table td {
	cursor: pointer !important;
	word-break: break-all;
	word-wrap: break-word;
}

.load_bg {
	background: #000;
	opacity: 0.1;
	left: 0px;
	top: 0px;
	position: fixed;
	height: 100%;
	width: 100%;
	overflow: hidden;
	z-index: 10000;
}

.load_img {
	left: 50%;
	top: 180px;
	position: fixed;
	height: 50px;
	overflow: hidden;
	z-index: 20000;
}

a.check {
	margin-bottom: 10px;
}

@media ( min-width : 768px) and (max-width: 1200px) {
	.backup-text {
		width: 100px !important;
	}
}
	</style>
</head>
<body  class="no-skin">

<div  class="load_bg" style="display:none"></div>
<img src="http://img.xmiles.cn/commentloading.gif" class="load_img" style="display:none"/>
	<div class="page-content"> 
		<form id="queryForm" action="" method="POST"> 
			<div class="page-content-area"> 
				<div class="row">
  					<div class="col-sm-12">
						<div class="widget-box" style="border:0px solid #ccc; border-top:none;border-bottom:none;margin-top:15px;">
							<hr style="margin-top:0px;margin-bottom:0x">
							<div class="widget-header widget-header-blue widget-header-flat">
									<h4 class="widget-title">选择条件进行查询</h4>
									<div class="widget-toolbar">
										<a href="#" data-action="collapse">
											<i class="ace-icon fa fa-chevron-up"></i>
										</a>
									</div>
							</div>
							<div class=" widget-body">
								<div class="widget-main" >
											
									<div class="form-group col-xs-12 col-sm-4">
										<label class="col-sm-2 control-label" style="text-align:right">所属活动：</label>
										 <div class="col-sm-6">
											<div class="input-daterange input-group col-sm-6">
													<s:select id="activityList" name="activity" list="%{paramsMap.activityList}" listKey="activity_id" listValue="activity_name" 
													headerKey="" headerValue="------请选择------" cssClass="form-control"></s:select>
											</div>
										</div>
									</div>
									
									<div class="form-group col-xs-12 col-sm-4">
										<label class="col-sm-3 control-label"  style="text-align:right">用户手机号：</label>
										 <div class="col-sm-4">
											<div class="input-daterange input-group col-sm-12">
												<input type="text" name="phone" class="form-control text-left">
											</div>
										</div>
									</div>
									
  									 <div class="form-group col-xs-12 col-sm-4 ">	 
										<label class="col-sm-2 control-label"  style="text-align:right"  for="sex">登记时间:</label>
										<div class="col-sm-6">
											<div class="input-daterange input-group col-sm-12">
												<input type="text" data-date-format="yyyy-mm-dd hh:ii" class="fromDate date-picker input-sm form-control" style="padding-left:0px" name="startTime">
												<span class="input-group-addon" style="width:6px">
													<i class="fa fa-exchange"></i>
												</span>
												<input type="text" data-date-format="yyyy-mm-dd hh:ii" class="endDate date-picker input-sm form-control" style="padding-left:0px" name="endTime">
											</div>
										</div>
									</div>
									
									<div class="form-group col-xs-10 col-sm-4">
										<label class="col-sm-2 control-label"  style="text-align:right" >领奖资格:</label>
										 <div class="col-sm-4">
											<div class="input-daterange input-group col-sm-6">
												<select name="status">
													<option value="">全部</option>
													<option value="1">是</option>
													<option value="0">否</option>
												</select>
											</div>
										</div>
									</div>
									
									<div class="form-group col-xs-10 col-sm-4">
										<label class="col-sm-2 control-label"  style="text-align:right" >可充值:</label>
										 <div class="col-sm-4">
											<div class="input-daterange input-group col-sm-6">
												<select name="isrechar">
													<option value="">全部</option>
													<option value="1">是</option>
												</select>
											</div>
										</div>
									</div>
									
									<div class="form-group col-xs-10 col-sm-4">
										<label class="col-sm-2 control-label"  style="text-align:right" >再次充值:</label>
										 <div class="col-sm-4">
											<div class="input-daterange input-group col-sm-6">
												<select name="isfail">
													<option value="">全部</option>
													<option value="1">是</option>
												</select>
											</div>
										</div>
									</div>
		
								</div><!-- /.widget-main -->
							</div><!-- /.widget-body -->
					</div><!-- /.widget-box -->
				</div><!-- /.col-sm-12 -->
					
					<div class="col-md-12 center">
						<div class="clearfix form-actions">
				
							<button class="btn btn-purple  no-border" type="button" name="btn-query" onclick="query_any()" id="btn-query" > 
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i> 
								查询 
							</button> 
							&nbsp;&nbsp;&nbsp;
							<button class="btn btn-grey  no-border" type="reset">
								<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
								重置
							</button>
							
				 		 </div>
		  			 </div>
				
				</div><!-- /.row -->
					 
				<div class="row">
					<div class="col-xs-12">
						<a id="loadButton" href="javascript:void(0)" class="btn btn-success btn-small" style="display: none" id="output2" onclick="loadlist()">导出CSV</a>&nbsp;&nbsp;&nbsp;
					</div>
				</div>
					 
				<hr style="display:none;" id="delete_hr">
					<div class="row">
					<div class="col-xs-12">
						<table id="jquery-table" class="table table-striped table-bordered table-hover">
						</table>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div><!-- /.page-content-area -->
		</form>
	</div><!-- /.page-content -->
				
<%@ include file="/common/common-js.jsp" %>

<!-- inline scripts related to this page -->

<script type="text/javascript">

	//导出csv
	function loadlist(){
		var form = document.forms["queryForm"];
		form.action= ctx + "/userinfoset/download.action";
		form.submit();
	}

	//【查询】按钮Click事件
	function query_any() {
		$("#loadButton").show();
		$(".load_bg").removeAttr("style");
		$(".load_img").removeAttr("style");
		if (jqTable != null) {
			jqTable.fnDraw();
		} else {
			loaddata();
		}
		$("#delete_hr").attr("style", "margin-top:0px;margin-bottom:20px;display:block");
	}
	var jqTable = null;
	var loaddata = function() {
		jQuery(function($) {
			jqTable = $('#jquery-table').dataTable(
					{
						"columnDefs" : [ 
						{
							"title" : '活动名称',
							"targets" : [ 0 ],
							"data" : "activity_name",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '手机号',
							"targets" : [ 1 ],
							"data" : "mobnum",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '登记时间',
							"targets" : [ 2 ],
							"data" : "utime",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '甲方申请时间',
							"targets" : [ 3 ],
							"data" : "apply_date",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '领奖资格',
							"targets" : [ 4 ],
							"data" : "comp",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '充值金额',
							"targets" : [ 5 ],
							"data" : "amount",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '话费充值状态',
							"targets" : [ 6 ],
							"data" : "money_status",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%",
							"render": function(value, type, row) {
								switch (row.money_status) {
								case '-1':
									var temp = "订单不存在";
									break;
								case '0':
									var temp = "充值中"; 
									break;
								case '1':
									var temp = "充值成功";
									break;
								case '2':
									var temp = "订单提交失败";
									break;
								case '3':
									var temp = "初始化订单";
									break;
								case '4':
									var temp = "部分订单提交失败";
									break;
								case '5':
									var temp = "部分订单充值失败";
									break;
								case '9':
									var temp = "充值失败";
									break;
								default:
									 var temp = row.money_status;
									break;
								}
								return temp;
							}
						},
						{
							  "title":'操作',
							  "targets": [7],
							  "data": "id",
							  "class": "center",
							  "width": "5%",
							  "bSortable": false,
							  "render": function(value, type, row) {
								  if (row.comp=='是' && row.money_status == '-1') {
								  	  var temp = "<input class='btn btn-success btn-sm' type='button' name='PK' value='充值' onclick='recharge("+ row.id +")'/>";
								  } else if (row.comp=='是' && (row.money_status == '9' || row.money_status == '5' || row.money_status == '4')) {
									  var temp = "<input class='btn btn-success btn-sm' type='button' name='PK' value='再次充值' onclick='recharge("+ row.id +", 1)'/>"; 
								  } else { 
									  var temp = "";
								  }
	                       		return temp;
				    	  	  }
				    	}
						],
						"sAjaxSource" : ctx + "/userinfoset/queryList.action", // 数据源URL
						"fnServerData" : function(sSource, aoData,
								fnCallback) {//从服务器请求数据
							var data = $('#queryForm').serializeObject();
							data.aoData = JSON.stringify(aoData);
							$.ajax({
								"dataType" : 'json',
								"type" : "POST",
								"url" : sSource,
								"data" : data,
								"success" : function(resp) {
									fnCallback(resp);
									initListPage();
									$(".load_bg").attr("style",
											"display:none");
									$(".load_img").attr("style",
											"display:none");
								},
								"error" : function(XMLHttpRequest,
										textStatus, errorThrown) {
									$(".load_bg").attr("style",
											"display:none");
									$(".load_img").attr("style",
											"display:none");
									alert('请求服务器错误,请刷新重试！！');//错误提示，包括服务器重启导致的session失效
								},
							});
						},
						"sScrollXInner" : "100%",
						"sScrollY" : "100%",//如果不设置，IE会有问题
						"aaSorting" : [ [ 1, "desc" ] ]
					});
		});
	}
	jQuery(function() {
		$(".date-picker").datepicker({
			autoclose : true,
			format : 'yyyy-mm-dd'
		});
		$("#activityList").combobox();
	});
	
	function recharge(id, type){
		if (window.confirm('确认充值操作')) {
			$.ajax({
				"type" : "POST",
				"data" : {"id":id, "ch_type":type},
				"dataType" : 'json',
				"url" : ctx + '/userinfoset/recharge.action',		
				"success" : function(data) {
					alert(data.message);
					query_any();
				},
				"error" : function() {
					alert("处理失败");
				}
			});
		}
	}
	
</script>
</body>
</html>
